#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 7;

struct Edge {
    int to, next;
};

Edge edges[MAXN << 1];
int head[MAXN], edge_count = 0;
bool infected[MAXN];

inline void add_edge(int u, int v) {
    edges[++edge_count] = {v, head[u]};
    head[u] = edge_count;
}

int bfs(int n) {
    queue<int> q;
    int nf = 0, days = 0, spread = 1;
    
    infected[1] = true;
    q.push(1);
    
    while (!q.empty()) {
        int farm = q.front();
        q.pop();
        
        for (int i = head[farm]; i != -1; i = edges[i].next) {
            int neighbor = edges[i].to;
            if (!infected[neighbor]) 
                nf++, infected[neighbor] = true, q.push(neighbor);
        }

        for (; spread <= nf; days++, spread <<= 1)
            ;
        
        days += nf, spread = 1, nf = 0;
    }
    
    return days;
}

int main() {
    int n, u, v;
    cin >> n;
    memset(head, -1, sizeof(head));
    for (int i = 1; i < n; i++) {
        int u, v;
        add_edge(u, v), add_edge(v, u);
    }
    
    cout << bfs(n) << endl;
    
    return 0;
}
